import {reqGoodsList} from '@/api'

const state = {
   goodsListInfo:{}
}
const mutations = {
    RECRIVE_GOODSLISTINFO(state,goodsListInfo){
        state.goodsListInfo = goodsListInfo
    }
}
const actions = {
    async getGoodsListInfo({commit},searchParams){
        const result = await reqGoodsList(searchParams)
           if (result.code === 200) {
               return commit('RECRIVE_GOODSLISTINFO',result.data)
           }
    }
}
const getters = {
    attrsList(state){
        // 为什么要有空数组,因为我们要保证vue当中获取到的不是undefined,如果是undefined,很有可能报错
        // 
        return state.goodsListInfo.attrsList || []
    },
    goodsList(state){
        return state.goodsListInfo.goodsList || []
    },
    trademarkList(state){
        return state.goodsListInfo.trademarkList || []
    }
}

export default {
    state,
    mutations,
    actions,
    getters
}